/*
 * To change this license header, choose License Headers in Project Properties. To change this
 * template file, choose Tools | Templates and open the template in the editor.
 */
package chalmers.game.subterranean.ui;

import chalmers.game.subterranean.ui.view.*;
import chalmers.game.subterranean.ui.view.world.LevelGrid;
import chalmers.game.subterranean.util.options.Backgrounds;
import chalmers.game.subterranean.util.options.WorldValues;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;

/**
 * @author TH
 */
public class SceneFactory {

    /**
     * This will make a predefined scene we will use as a launcher scene to give the application
     * something nice to look at.
     *
     * @return Scene
     */
    public static Scene makeStartScene() {

        Label welcomeText = new Label("subterranean");
        welcomeText.setFont(new Font(130));
        welcomeText.setAlignment(Pos.TOP_CENTER);

        Label pressSpace = new Label("Press SPACE to start");
        pressSpace.setFont(new Font(20));
        pressSpace.setAlignment(Pos.BOTTOM_RIGHT);

        BorderPane root = new BorderPane();
        root.setCenter(welcomeText);
        root.setBottom(pressSpace);
        BorderPane.setAlignment(pressSpace, Pos.BOTTOM_RIGHT);
        BorderPane.setMargin(pressSpace, new Insets(0, 20, 10, 0));

        Scene theStartScene =
            new Scene(root, WorldValues.GAME_RESOLUTION_WIDTH, WorldValues.GAME_RESOLUTION_HEIGHT);

        return theStartScene;
    }

    public static Scene makeGameScene() {
        Pane root = new Pane();
        Pane rootone = new Pane();
        Pane worldPane = new Pane();

        root.setBackground(Backgrounds.WORLD_BG);
        rootone.setBackground(Backgrounds.WORLD_BG);

        EndScreen es = new EndScreen();
        HUD hud = new HUD();
        LevelGrid blocks = new LevelGrid(1);
        Player player = new Player();
        Minors minors = new Minors(worldPane);
        World world = new World(worldPane);

        rootone.setClip(player.getTorch()); // This will hide everything outside the torch
        root.getChildren().addAll(rootone, hud.view, es.view);
        rootone.getChildren().addAll(worldPane, player.img);
        //ShopView shop = new ShopView();  TODO shop disabled.
        //worldPane.getChildren().addAll(blocks.grid, shop.layout);
        worldPane.getChildren().addAll(blocks.grid);

        Scene theGameScene =
            new Scene(root, WorldValues.GAME_RESOLUTION_WIDTH, WorldValues.GAME_RESOLUTION_HEIGHT);
        SoundHandler soundHandler = new SoundHandler();
        return theGameScene;
    }
}
